HAL TimeBase TIM How to Use

group TimeBase_TIM_How_To_Use

How to use this pattern

  • Add the required files to the project:

    • hal_timebase_tim.c

    • The corresponding TIM HAL driver (stm32c5xx_hal_tim.c).

  • Enable the TIM HAL module:

    • In stm32c5xx_hal_conf.h, uncomment or add: #define USE_HAL_TIM_MODULE 1U

  • Initialize the TIM peripheral instance used as the time base:

    • Use the initialization functions, either generated by STM32CubeMX2 or the TIM template (mx_timx.c/.h).

  • Ensure the link between files:

    • The connection between stm32c5xx_hal_timebase_tim.c and mx_timx.h is managed through aliases in stm32c5xx_hal_timebase.h.

  • Example of time base initialization:

    • HAL_InitTick(HAL_TICK_FREQ_1KHZ, 0); // 1 ms tick, priority 0

  • Suspend/resume the tick if needed:

  • Note:

    • This component is ready-to-use and read-only. No customization is required.